import java.util.*;
public class TwoThreadOperationOnList {
    public static volatile List<Integer> inputList = Arrays.asList(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
//    public static volatile int[] inputArray = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
    public static void main(String args[]) {
        Runnable r1 = new Runnable1();
        Thread t1 = new Thread(r1);

        Runnable r2 = new Runnable2();
        Thread t2 = new Thread(r2);

        t1.start();
        t2.start();

        System.out.println(inputList);
        sleep(100);
        System.out.println(inputList);

    }

    private static void sleep(int value) {
        try {
            Thread.sleep(value);
        } catch (InterruptedException e) {
            e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
        }
    }
}

class Runnable1 extends TwoThreadOperationOnList implements Runnable {
    public void run() {
        System.out.println("First Thread started");
        for (int i = 0; i < inputList.size(); i = i + 2) {
            System.out.println(inputList.get(i) + " *");
        }
    }
}

class Runnable2 extends TwoThreadOperationOnList implements Runnable {
    public void run() {
        System.out.println("Second Thread started");
        for (int i = inputList.size() - 2 ; i > 0; i = i - 2) {
            System.out.println(inputList.get(i));
            inputList.set(i, null);
        }
    }
}